//
//  LogisticsCell.m
//  PigMarket
//
//  Created by 张敬 on 2019/8/19.
//  Copyright © 2019年 pigmarket.oc. All rights reserved.
//

#import "LogisticsCell.h"

@implementation LogisticsCell

#pragma mark - lifecycle methods

- (void)setupUI
{
    [self addSubview:self.tipIcon];
    [self addSubview:self.bgView];
    [self.bgView addSubview:self.timeLab];
    [self.bgView addSubview:self.instructionLab];
    [self.bgView addSubview:self.contactLab];
}

- (void)setupLayout
{
    {
        _tipIcon.size = CGSizeMake(15, 15);
        _tipIcon.mj_x = 22;
        _tipIcon.mj_y = 5;
    }
    
    {
        _bgView.size = CGSizeMake(KScreenWidth - 62, 82);
        _bgView.mj_y = 10;
        _bgView.mj_x = 48;
    }
    
    {
        _timeLab.size = CGSizeMake(_bgView.width - 50, 14);
        _timeLab.mj_x = 20;
        _timeLab.mj_y = 12;
    }
    
    {
        _instructionLab.size = CGSizeMake(_timeLab.width, 20);
        _instructionLab.mj_x = _timeLab.mj_x;
        _instructionLab.mj_y = _timeLab.bottom + 5;
    }
    
    {
        _contactLab.size = CGSizeMake(_timeLab.width, 20);
        _contactLab.mj_x = _timeLab.mj_x;
        _contactLab.mj_y = _instructionLab.bottom;
    }
    
    CAShapeLayer *line = [CAShapeLayer layer];
    line.fillColor = UIColorFromRGB(0xD5D5D5).CGColor;
    UIBezierPath *path = [UIBezierPath bezierPathWithRect:CGRectMake(29, _tipIcon.bottom + 15, 1, 60)];
    line.path = path.CGPath;
    [self.layer addSublayer:line];
    
}

#pragma mark - setter methods

- (void)setType:(LogisticsCellType)type
{
    switch (type) {
        case LogisticsCellType_Finish:
            {
                _tipIcon.image = [UIImage imageNamed:@"address_logistics_green"];
                _contactLab.hidden = NO;
                _bgView.height = 82;
                _instructionLab.textColor = UIColorFromRGB(0x333333);
            }
            break;
            
        default:
            {
                _tipIcon.image = [UIImage imageNamed:@"address_logistics_gray"];
                _contactLab.hidden = YES;
                _bgView.height = 62;
                _instructionLab.textColor = UIColorFromRGB(0x666666);

            }
            break;
    }
}

#pragma mark - getter methods

- (UIImageView *)tipIcon
{
    if (!_tipIcon) {
        _tipIcon = [UIImageView new];
        _tipIcon.image = [UIImage imageNamed:@"address_logistics_gray"];
    }
    return _tipIcon;
}


- (UIImageView *)bgView{
    
    if (!_bgView) {
        _bgView = [UIImageView new];
        _bgView.image = [UIImage imageNamed:@"Meat_Logistics_CellBg"];
    }
    return _bgView;
}


- (UILabel *)timeLab{
    
    if (!_timeLab) {
        _timeLab = [UILabel makeLabelWithText:@"2019-10-23 10:23:56" textColor:UIColorFromRGB(0x999999) font:mFont(12) textAliment:0];
    }
    return _timeLab;
}


- (UILabel *)instructionLab{
    
    if (!_instructionLab) {
        _instructionLab = [UILabel makeLabelWithText:@"您的订单已到武清区" textColor:UIColorFromRGB(0x666666) font:mFont(13) textAliment:0];
    }
    return _instructionLab;
}


- (UILabel *)contactLab{
    
    if (!_contactLab) {
        _contactLab = [UILabel makeLabelWithText:@"联系人：刘伟业" textColor:UIColorFromRGB(0x333333) font:mFont(13) textAliment:0];
    }
    return _contactLab;
}


@end
